<%@ page language="java" import="java.util.*,com.tjsinfo.tjsoa.common.ToolKit,com.tjsinfo.tjsoa.system.vo.User" pageEncoding="UTF-8"%>


<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
User sessionuser=ToolKit.getSessionUser(request);
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <base href="<%=basePath %>"/>
	<title>天津市计算机研究所</title>
	<meta http-equiv="x-ua-compatible" content="ie=7" />	
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link href="<%=basePath %>articles/style/css.css" rel="stylesheet" type="text/css" />
	<link href="<%=basePath %>articles/style/houtaianniu.css" rel="stylesheet" type="text/css" />
	<link href="<%=basePath %>ajaxFramework/ext-2.1/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
	<style type="text/css">
	  .red-row{
				background-color: red !important;
			}
		.yellow-row{
				background-color: yellow !important;
			}
		.blue-row{
				background-color: blue !important;
			}				
		.silk-add{
        background-image:url(<%=basePath %>ajaxFramework/ext-2.1/shared/icons/fam/add.gif) !important;
	</style>
	<script  src="<%=basePath %>ajaxFramework/ext-2.1/adapter/ext/ext-base.js"></script>
	<script  src="<%=basePath %>ajaxFramework/ext-2.1/ext-all.js"></script>
	<script src="<%=basePath %>ajaxFramework/ext-2.1/source/locale/ext-lang-zh_CN.js"></script>
    <script src="<%=basePath %>ajaxFramework/ext-2.1/menu/EditableItem.js"></script>
	<script src="<%=basePath %>ajaxFramework/ext-2.1/menu/RangeMenu.js"></script>
	<script src="<%=basePath %>ajaxFramework/ext-2.1/grid/GridFilters.js"></script>
	<script src="<%=basePath %>ajaxFramework/ext-2.1/grid/filter/Filter.js"></script>
	<script src="<%=basePath %>ajaxFramework/ext-2.1/grid/filter/StringFilter.js"></script>
	<script src="<%=basePath %>ajaxFramework/ext-2.1/grid/filter/DateFilter.js"></script>
	<script src="<%=basePath %>ajaxFramework/ext-2.1/grid/filter/ListFilter.js"></script>
	<script src="<%=basePath %>ajaxFramework/ext-2.1/grid/filter/NumericFilter.js"></script>
	<script src="<%=basePath %>ajaxFramework/ext-2.1/grid/filter/BooleanFilter.js"></script>
	<script  src="<%=basePath %>ajaxFramework/jQuery/jquery.js"></script>
	<script  src="<%=basePath %>articles/manage/js/rulesManageList.js"></script>
	<script >

	function initArticlesList(){
		 Ext.BLANK_IMAGE_URL=Ext.get('basePath').getValue()+"ajaxFramework/ext-2.1/resources/images/default/s.gif";

		 Ext.menu.RangeMenu.prototype.icons = {
		 	  gt: './ajaxFramework/ext-2.1/img/greater_then.png', 
		 	  lt: './ajaxFramework/ext-2.1/img/less_then.png',
		 	  eq: './ajaxFramework/ext-2.1/img/equals.png'
		 	};
		 Ext.grid.filter.StringFilter.prototype.icon = './ajaxFramework/ext-2.1/img/find.png';
		
		 var filters = new Ext.grid.GridFilters({
			 cleanParams: function(p) {  // 清除参数的方法，要保留PagingToolbar分页用的两个参数
			   //var regex = new RegExp("^" + this.paramPrefix + "\[[0-9]+\]");
			   for(var key in p) {
			      if( key != 'start' && key != 'limit' )
			   //if(regex.test(key)) {
			    delete p[key];
			            //}
			               }
	          },
		     buildQuery: function(filters) {	
			  // filters 就是getFilterData返回的值, 代码中push入去的对象
			  var p = {};
			  for(var i=0, len=filters.length; i<len; i++) {
			      var f = filters[i];
			      
			      // 取得在GridFilters中定义的filters中的一个filter
			      var filter = this.getFilter( f.field );
			      // 取得传递到server的参数名称
			      var name = (filter.paramName ? filter.paramName : filter.dataIndex);
			      var value = (filter.paramValue ? filter.paramValue : f.data['value']);
			      
			      if( value != '' ) p[ name ] = value;
			  }
			  return p;
			   },	
			  filters:[
			 	{type: 'string',  dataIndex: 'title'},
			 	{type: 'string',  dataIndex: 'wenhao'},
			 	{type: 'string',  dataIndex: 'danwei'},
			 	{type: 'string',  dataIndex: 'bumen'},
			 	{type: 'date',  dataIndex: 'createdatestr'},
			 	{type: 'string',  dataIndex: 'tablename'},
			 	{type: 'date',  dataIndex: 'uploaddatestr'}
		]}); 
		 
		 /**
		 * 表格各列定义
		 */
		  	var _columnModle = new Ext.grid.ColumnModel({
		 		columns:[
		 		{
		 			header: "制度名称", menuDisabled: false,dataIndex:'title',sortable:true,renderer:function(s,m,rec){
		 				var str = "<a href=\"" + Ext.get('basePath').getValue()+ "tjsinfo/tjsoa/articles/Rules.do?method=download&id="+rec.data.id+"\" >"+rec.data.title+"</a>";
		 				return str;
		 			}
		 		},{
		 			header: "文号", menuDisabled: false,dataIndex:'wenhao',width:30
	 			},{
		 			header: "发文单位", menuDisabled: false,dataIndex:'danwei',width:20
	 			},
	 			{
		 			header: "上传部门", menuDisabled: false,dataIndex:'bumen',width:30
		 		},
	 			{
		 			header: "发文时间", menuDisabled: false,dataIndex:'createdatestr',width:30
		 		},
	 			{
		 			header: "相关表格", menuDisabled: false,dataIndex:'tablename',width:30,renderer:function(s,m,rec){
		 				var str = "";
		 				if(rec.data.tablename !=""&& rec.data.tablename !=null){
		 					str = "<a href=\"" +Ext.get('basePath').getValue()+ "tjsinfo/tjsoa/articles/Rules.do?method=downloadTable&"+"id="+rec.data.id+"\">"+rec.data.tablename+"</a>";	
		 				}
		 				return str;
		 			}
		 		},
	 			{
		 			header: "上传时间", menuDisabled: false,dataIndex:'uploaddatestr',width:30
		 		}]
		 	});

		  	/**
			 * 获取表格中显示的内容
			 */
				_store = new Ext.data.JsonStore({
			 		fields:['id','title','wenhao','danwei','bumen','createdatestr','uploaddatestr','alertdatestr','tablename','handler','showOrder','state'],
			 		url: Ext.get('basePath').getValue()+ 'tjsinfo/tjsoa/articles/Rules.do?method=getRulesList',
			 		root: 'aricleslist',
		            totalProperty: 'totalCount'
			 	});
		  		
			/**   
			 * 翻页工具栏
			 */		
			 var bbar = new Ext.PagingToolbar({
				pageSize:20,
				store:_store,
				plugins: filters,
				//显示右下角信息
				   displayInfo:true,
				   displayMsg:'当前记录 {0} -- {1} 条 共 {2} 条记录',
			       prevText:"上一页",
				   nextText:"下一页",
				   refreshText:"刷新",
				   lastText:"最后页",
				   firstText:"第一页",
				   beforePageText:"当前页",
				   afterPageText:"共{0}页",
				   emptyMsg:'没有记录',
				   items:[
		                '-','每页显示行数:',
		                 {  name:'txtpagesize',
		                	id:'txtpagesize',
		                	xtype:'numberfield',
							emptyText:_pagesize,
							width:30          
		                },{
		                	text: '确定',
					            handler: function(){
					                bbar.pageSize = parseInt(Ext.getCmp('txtpagesize').getValue());
							        _store.reload({params:{start:0,limit:bbar.pageSize}}); 
					                }
		            }]
			});
		  	 
		  	/**   
			 * 翻页工具栏
			 */
			 	var _toolbar;
			
			 	 _toolbar = new Ext.Toolbar({
			         items: []
					});

			 	
				/**   
				 * 翻页工具栏
				 */
				var _table = new Ext.grid.GridPanel({
					colModel:_columnModle,
					sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
			 		store:_store,
				    width: Ext.get("showRegional").getWidth(),
				    height:Ext.get("showRegional").getHeight(),
				    renderTo:Ext.get('showRegional'),
				    frame: true,
				    viewConfig:{
						forceFit:true,
						getRowClass:function(record,rowIndex,p,ds){
							if(record.get('state') == 0)
							{
								
								return 'yellow-row';
							}							
						}
					},
				    clicksToEdit:1, 
				    layout : 'fit',// 表格内列内容填充满,按列头比例填充 
				    loadMask:{ 
					msg : '数据加载中，请稍候...' 
					}, 
					plugins: filters,
				    stripeRows:true,
				    tbar: _toolbar,
				    bbar:bbar
				});
				_store.load({params:{start:0, limit:20}});
		  	
	}
	</script>
  </head>
  
    <body  onload="initArticlesList()">
  	  <div id="index" style="width:100%;height:600px;">
	  <div id="showRegional" style="width:100%;height:100%;"></div>
	  <input type="hidden" value="<%=basePath %>" id="basePath"/>
	  </div>
  </body>
  
</html>
